home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / formats / ps16form / ctop16.asm next >
Assembly Source File  |  1993-04-26  |  6KB  |  176 lines

  1. ;───────────────────────────────────────────────────────────────────────────────
  2. ; Convert to PS16 - CTOP16 v1.0
  3. ;
  4. ; Written by Joshua C. Jensen                              Last update: 04/27/93
  5. ;
  6. ; For those of you who wanted to know the file format in advance, here it is.
  7. ; Please, please, do not change and redistribute this code.  The drivers are
  8. ; more or less done.  I'll be releasing them in a few days.
  9. ;───────────────────────────────────────────────────────────────────────────────
  10.  
  11.                 ideal
  12.                 P286
  13.                 model   Small
  14.                 jumps
  15.  
  16. include "music.inc"
  17.  
  18. segment MyCode
  19.  
  20.         assume    cs:MyCode,ds:MyData
  21.  
  22. include         "modload.asm"
  23.  
  24. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  25. ; LoadCommandLine - Pulls the MOD and PS16 filename from the command line.
  26. ;   Out: Carry set if error.
  27. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  28. proc            LoadCommandLine near
  29.                 ; ▒▒▒▒▒ Setup the segment and offset.
  30.                 mov     ax, MyData
  31.                 mov     es, ax
  32.                 mov     ds, [cs:PspAddress]
  33.                 mov     si, 128
  34.         cld
  35.  
  36.                 ; ▒▒▒▒▒ Get the length in AL.
  37.                 lodsb
  38.                 or      al, al
  39.         je    @@noargv
  40.  
  41. @@MoreThanOne:  ; ▒▒▒▒▒ Setup the end offset in BX.
  42.                 mov     bx, si
  43.                 inc     bx
  44.                 xor     ah, ah
  45.                 add     bx, ax
  46.  
  47. @@TopLoop:      ; ▒▒▒▒▒ If we make it to the end, then something was wrong.
  48.                 cmp     bx, si
  49.         je    @@noargv
  50.  
  51.                 ; ▒▒▒▒▒ Kill leading spaces.
  52.                 lodsb
  53.                 cmp     al, ' '
  54.         je    @@TopLoop
  55. ────────────────────────────────────────────────────────────────────────────────
  56.                 ; ▒▒▒▒▒ We are at the input filename now.
  57.                 dec     si              ; Go back to pick up the character again.
  58.                 mov     di, offset ModInput
  59.                 mov     cx, 80
  60. @@TopGet:       ; ▒▒▒▒▒ If we reach the end, then something is wrong.
  61.                 cmp     bx, si          ; If we reach the end, then something
  62.                 je      @@noargv
  63.                 lodsb                   ; Pick up a character.
  64.                 stosb
  65.                 cmp     al,13           ; Something is wrong.
  66.                 je      @@noargv
  67.                 cmp     al,'.'          ; If it is a period, then don't store
  68.                 jne     @@NotPeriod     ;   .MOD extension.
  69.                 mov     ah,1            ; Set "." flag.
  70. @@NotPeriod:    cmp     al,' '          ; If it is a space
  71.                 je      @@DoSpace1
  72.                 loop    @@TopGet
  73. @@DoSpace1:     dec     di
  74. @@StoreMod:     or      ah,ah
  75.         jne    @@JustZero
  76.                 mov     [Byte es:di],'.'
  77.                 mov     [Byte es:di+1],'M'
  78.                 mov     [Byte es:di+2],'O'
  79.                 mov     [Byte es:di+3],'D'
  80.                 add     di,4
  81. @@JustZero:     mov     [Byte es:di],0
  82. ────────────────────────────────────────────────────────────────────────────────
  83. @@SpLoop2:      ; ▒▒▒▒▒ If we make it to the end, then something was wrong.
  84.                 cmp     bx, si
  85.         je    @@noargv
  86.  
  87.                 ; ▒▒▒▒▒ Kill leading spaces.
  88.                 lodsb
  89.                 cmp     al, ' '
  90.                 je      @@SpLoop2
  91. ────────────────────────────────────────────────────────────────────────────────
  92.                 ; ▒▒▒▒▒ We are at the output filename now.
  93.                 dec     si              ; Go back to pick up the character again.
  94.                 mov     di, offset PS16Output
  95.                 mov     cx, 80
  96.                 xor     ah,ah
  97. @@TopPS16:      ; ▒▒▒▒▒ If we reach the end, then something is wrong.
  98.                 cmp     bx, si          ; If we reach the end, then something
  99.                 je      @@noargv
  100.                 lodsb                   ; Pick up a character.
  101.                 cmp     al,13           ; Something is wrong.
  102.                 je      @@StorePS16
  103.                 cmp     al,'.'          ; If it is a period, then don't store
  104.                 jne     @@NotPeriod2    ;   .P16 extension.
  105.                 mov     ah,1            ; Set "." flag.
  106. @@NotPeriod2:   stosb
  107.                 loop    @@TopPS16
  108. @@StorePS16:    or      ah,ah
  109.                 jne     @@JustZero2
  110.                 mov     [Byte es:di],'.'
  111.                 mov     [Byte es:di+1],'P'
  112.                 mov     [Byte es:di+2],'1'
  113.                 mov     [Byte es:di+3],'6'
  114.                 add     di,4
  115. @@JustZero2:    mov     [Byte es:di],0
  116.                 clc
  117.         ret
  118. @@noargv:    stc
  119.         ret
  120. endp        LoadCommandLine
  121.  
  122. proc            Error near
  123.                 mov     ax,MyData
  124.         mov    ds,ax
  125.         mov    ah,9
  126.                 int     21h
  127.         mov    ax,4C00h
  128.         int    21h
  129. endp            Error
  130.  
  131. PspAddress    dw    ?
  132. SizeOfProg      dw      ?
  133. TopOfData    dw    ?
  134. proc        Main
  135. Start:          cli
  136.                 mov     ax,stackseg
  137.                 mov     ss,ax
  138.                 mov     sp,offset EndOfStack
  139.                 sti
  140.                 mov     [cs:PspAddress],es
  141.                 mov     ax,zzzzzseg
  142.                 inc     ax
  143.                 mov     [cs:TopOfData],ax
  144.  
  145.                 call    LoadCommandLine
  146.                 mov     cx,seg ModInput
  147.                 mov     dx,offset ModInput
  148.                 mov     bx,seg PS16Output
  149.                 mov     si,offset PS16Output
  150.                 mov     ax,[cs:TopOfData]
  151.                 call    MOD_Convert
  152.  
  153. @@Exit:         mov     ax,4C00h
  154.                 int     21h
  155. endp        Main
  156.  
  157. ends        MyCode
  158.  
  159. segment         MyData
  160. ModInput        db      80 dup (?)
  161. PS16Output      db      80 dup (?)
  162. ends            MyData
  163.  
  164. segment         stackseg
  165.                 db      511 dup (?)
  166. EndOfStack      db      ?
  167. ends            stackseg
  168.  
  169. segment zzzzzseg
  170.     db    16 dup (?)
  171. ends    zzzzzseg
  172.  
  173.         end     Start
  174.  
  175.  
  176.